package com.seuic.hnjiningposapp.hnapps.ui.view.dialog;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.core.CenterPopupView;
import com.seuic.hnjiningposapp.R;

import butterknife.BindView;

/**
 * 错误dialog
 */
public class ErrorPopup extends BaseCenterPopupView {

    @BindView(R.id.right_btn)
    Button do_btn;
    @BindView(R.id.tv_msg)
    TextView mTvMsg;
    Context mContext;
    OnFinishCallbacked OnFinishCallbacked;

    private String msg;

    public ErrorPopup(@NonNull Context context) {
        super(context);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }



    public ErrorPopup(@NonNull Context context, OnFinishCallbacked OnFinishCallback) {
        super(context);
        this.mContext = context;
        this.msg = msg;
        this.OnFinishCallbacked = OnFinishCallback;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        mTvMsg.setText(msg);

        do_btn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                OnFinishCallbacked.finished();
            }
        });
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.error_popup_layout;
    }



    public interface OnFinishCallbacked {
        void finished();
    }

//    @Override
//    public void onClick(View v) {
//        switch (v.getId()) {
//            case R.id.right_btn:
//                mFinishCallback.finish();
//                break;
//        }
//    }
}
